package com.ruoyi.zxjd.work.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.zxjd.work.domain.WorkTemplateTable8;
import com.ruoyi.zxjd.work.domain.bo.WorkProgressBO;
import com.ruoyi.zxjd.work.service.IWorkProgressService;
import com.ruoyi.zxjd.work.service.IWorkTemplateTable8Service;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 纪检监察机关反映问题线索处置情况登记Controller
 *
 * @author ruoyi
 * @date 2021-03-22
 */
@Controller
@RequestMapping("/work/templatetable8")
public class WorkTemplateTable8Controller extends BaseController {
    private String prefix = "work/templatetable8";

    @Autowired
    private IWorkTemplateTable8Service workTemplateTable8Service;

    @Autowired
    private IWorkProgressService workProgressService;

    @Autowired
    private WorkProgressController workProgressController;


    @RequiresPermissions("work:templatetable8:view")
    @GetMapping()
    public String templatetable8() {
        return prefix + "/templatetable8";
    }

    /**
     * 查询纪检监察机关反映问题线索处置情况登记列表
     */
    @RequiresPermissions("work:templatetable8:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WorkTemplateTable8 workTemplateTable8) {
        startPage();
        List<WorkTemplateTable8> list = workTemplateTable8Service.selectWorkTemplateTable8List(workTemplateTable8);
        return getDataTable(list);
    }

    /**
     * 导出纪检监察机关反映问题线索处置情况登记列表
     */
    @RequiresPermissions("work:templatetable8:export")
    @Log(title = "纪检监察机关反映问题线索处置情况登记", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WorkTemplateTable8 workTemplateTable8) {
        List<WorkTemplateTable8> list = workTemplateTable8Service.selectWorkTemplateTable8List(workTemplateTable8);
        ExcelUtil<WorkTemplateTable8> util = new ExcelUtil<WorkTemplateTable8>(WorkTemplateTable8.class);
        return util.exportExcel(list, "templatetable8");
    }

    /**
     * 新增纪检监察机关反映问题线索处置情况登记
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存纪检监察机关反映问题线索处置情况登记
     */
    @RequiresPermissions("work:templatetable8:add")
    @Log(title = "纪检监察机关反映问题线索处置情况登记", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WorkProgressBO workProgressBO) {
        return toAjax(workTemplateTable8Service.insertWorkTemplateTable8(workProgressBO));
    }

    /**
     * 新增保存纪检监察机关反映问题线索处置情况登记,并填报下一份记录
     */
  /*  @RequiresPermissions("work:templatetable8:add")
    @Log(title = "纪检监察机关反映问题线索处置情况登记", businessType = BusinessType.INSERT)
    @PostMapping("/add/next")
    @ResponseBody
    public String addSaveAndNext(WorkProgressBO workProgressBO) {
        workTemplateTable8Service.insertWorkTemplateTable8(workProgressBO);

//        String pathUrl = workProgressController.fullIn(workProgressBO.getWorkProgress().getProgressId(), new ModelMap());

        String url = "http://localhost:8088/work/progress/fill_in/" + workProgressBO.getWorkProgress().getProgressId();
        return   redirect(url);
    }*/

    /**
     * 修改纪检监察机关反映问题线索处置情况登记
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap) {
        WorkTemplateTable8 workTemplateTable8 = workTemplateTable8Service.selectWorkTemplateTable8ById(id);
        mmap.put("workTemplateTable8", workTemplateTable8);
        return prefix + "/edit";
    }

    /**
     * 修改保存纪检监察机关反映问题线索处置情况登记
     */
    @RequiresPermissions("work:templatetable8:edit")
    @Log(title = "纪检监察机关反映问题线索处置情况登记", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WorkTemplateTable8 workTemplateTable8) {
        return toAjax(workTemplateTable8Service.updateWorkTemplateTable8(workTemplateTable8));
    }

    /**
     * 删除纪检监察机关反映问题线索处置情况登记
     */
    @RequiresPermissions("work:templatetable8:remove")
    @Log(title = "纪检监察机关反映问题线索处置情况登记", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(workTemplateTable8Service.deleteWorkTemplateTable8ByIds(ids));
    }

    /**
     * 删除纪检监察机关反映问题线索处置情况登记
     */
    @RequiresPermissions("work:templatetable8:remove")
    @Log(title = "纪检监察机关反映问题线索处置情况登记", businessType = BusinessType.DELETE)
    @GetMapping("/remove")
    @ResponseBody
    public AjaxResult removeByGet(String ids) {
        return toAjax(workTemplateTable8Service.deleteWorkTemplateTable8ByIds(ids));
    }

}
